﻿/********************************************************************
FileName    :   Bll_OS.cs
CreateTime  :   2020-11-09 04:52:48
BaseClass   :   Bll_OS
FileType    :   .cs
Author      :  minjie
*********************************************************************/


using System;
using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic;

using System.Data;
namespace OS.DAL
{
    /// <summary>
    /// Dal_jbxx_khdaH的摘要说明。
    /// </summary>
    public partial class Dal_jbxx_khdaH
    {
        /// <summary> 
        /// 更新一条数据(字符串) 2016-07-13更新 
        ///   2020-04-09 更新 minjie 
        /// </summary> 
        public string UpdateStr(jbxx_khdaH_Entity model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update jbxx_khdaH set ");

            if (model.DjLsh != null)
                strSql.Append(" DjLsh ='" + model.DjLsh + "',");

            if (model.DjBtZdh != null)
                strSql.Append(" DjBtZdh ='" + model.DjBtZdh + "',");

            if (model.DjFtZdh != null)
                strSql.Append(" DjFtZdh ='" + model.DjFtZdh + "',");

            if (model.DjStZdh != null)
                strSql.Append(" DjStZdh ='" + model.DjStZdh + "',");

            if (model.DjState != null)
                strSql.Append(" DjState ='" + model.DjState + "',");

            if (model.DjCount != null)
                strSql.Append(" DjCount ='" + model.DjCount + "',");

            if (model.bmh != null)
                strSql.Append(" bmh ='" + model.bmh + "',");

            if (model.bmmc != null)
                strSql.Append(" bmmc ='" + model.bmmc + "',");

            if (model.khbh != null)
                strSql.Append(" khbh ='" + model.khbh + "',");

            if (model.khmc != null)
                strSql.Append(" khmc ='" + model.khmc + "',");

            if (model.khgm != null)
                strSql.Append(" khgm ='" + model.khgm + "',");

            if (model.lxr != null)
                strSql.Append(" lxr ='" + model.lxr + "',");

            if (model.xwy != null)
                strSql.Append(" xwy ='" + model.xwy + "',");

            if (model.khlx != null)
                strSql.Append(" khlx ='" + model.khlx + "',");

            if (model.qybh != null)
                strSql.Append(" qybh ='" + model.qybh + "',");

            if (model.khqy != null)
                strSql.Append(" khqy ='" + model.khqy + "',");

            if (model.sjqymc != null)
                strSql.Append(" sjqymc ='" + model.sjqymc + "',");

            if (model.sjqybh != null)
                strSql.Append(" sjqybh ='" + model.sjqybh + "',");

            if (model.khsr != null)
                strSql.Append(" khsr ='" + model.khsr + "',");

            if (model.zkdj != null)
                strSql.Append(" zkdj ='" + model.zkdj + "',");

            if (model.zk != null)
                strSql.Append(" zk ='" + model.zk + "',");

            if (model.fkzk != null)
                strSql.Append(" fkzk ='" + model.fkzk + "',");

            if (model.sjhm != null)
                strSql.Append(" sjhm ='" + model.sjhm + "',");

            if (model.ljjf != null)
                strSql.Append(" ljjf ='" + model.ljjf + "',");

            if (model.dhhm != null)
                strSql.Append(" dhhm ='" + model.dhhm + "',");

            if (model.cjhm != null)
                strSql.Append(" cjhm ='" + model.cjhm + "',");

            if (model.dz != null)
                strSql.Append(" dz ='" + model.dz + "',");

            if (model.yb != null)
                strSql.Append(" yb ='" + model.yb + "',");

            if (model.dzyj != null)
                strSql.Append(" dzyj ='" + model.dzyj + "',");

            if (model.wz != null)
                strSql.Append(" wz ='" + model.wz + "',");

            if (model.khyh != null)
                strSql.Append(" khyh ='" + model.khyh + "',");

            if (model.zjhm != null)
                strSql.Append(" zjhm ='" + model.zjhm + "',");

            if (model.qqhm != null)
                strSql.Append(" qqhm ='" + model.qqhm + "',");

            if (model.hykh != null)
                strSql.Append(" hykh ='" + model.hykh + "',");

            if (model.mm != null)
                strSql.Append(" mm ='" + model.mm + "',");

            if (model.sfgs != null)
                strSql.Append(" sfgs ='" + model.sfgs + "',");

            if (model.ksye != null)
                strSql.Append(" ksye ='" + model.ksye + "',");

            if (model.bqjf != null)
                strSql.Append(" bqjf ='" + model.bqjf + "',");

            if (model.ljxf != null)
                strSql.Append(" ljxf ='" + model.ljxf + "',");

            if (model.scbksj != null)
                strSql.Append(" scbksj ='" + model.scbksj + "',");

            if (model.bz != null)
                strSql.Append(" bz ='" + model.bz + "',");

            if (model.zjycxfrq != null)
                strSql.Append(" zjycxfrq ='" + model.zjycxfrq + "',");

            if (model.zjycxfje != null)
                strSql.Append(" zjycxfje ='" + model.zjycxfje + "',");

            if (model.zjycxfdh != null)
                strSql.Append(" zjycxfdh ='" + model.zjycxfdh + "',");

            if (model.yskje != null)
                strSql.Append(" yskje ='" + model.yskje + "',");

            if (model.djye != null)
                strSql.Append(" djye ='" + model.djye + "',");

            if (model.djyh != null)
                strSql.Append(" djyh ='" + model.djyh + "',");

            if (model.djsj != null)
                strSql.Append(" djsj ='" + model.djsj + "',");

            if (model.xgyh != null)
                strSql.Append(" xgyh ='" + model.xgyh + "',");

            if (model.xgsj != null)
                strSql.Append(" xgsj ='" + model.xgsj + "',");

            if (model.dmmc != null)
                strSql.Append(" dmmc ='" + model.dmmc + "',");

            if (model.sqjf != null)
                strSql.Append(" sqjf ='" + model.sqjf + "'");


            strSql.Append(" where  DjLsh ='" + model.DjLsh + "' ");
            return strSql.ToString();
        }

        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="DjLsh">主键</param>
        /// <returns></returns>
        public bool Exists(int DjLsh)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from jbxx_khdaH");
            strSql.Append(" where   DjLsh =@DjLsh ");
            SqlParameter[] parameters = { new SqlParameter("@DjLsh", SqlDbType.Int, 4) };
            parameters[0].Value = DjLsh;
            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }
        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="DjLsh">主键</param>
        /// <returns></returns>
        public bool Exists(string khbh)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from jbxx_khdaH");
            strSql.Append(" where   khbh =@khbh ");
            SqlParameter[] parameters = { new SqlParameter("@khbh", SqlDbType.VarChar, 50) };
            parameters[0].Value = khbh;
            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }

    public bool Exists( string khbh,string sjhm,ref string bh)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  khbh from Jbxx_khdaH where sjhm='"+ sjhm + "' or khbh='"+ khbh + "'    ");
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj != null && obj.ToString() != "")
            {
                bh = obj.ToString();
                  return true;
            }
              
            else
                return false;
         
        }




        /// <summary> 
        /// 增加一条数据 
        /// </summary> 
        public bool Add(jbxx_khdaH_Entity model, ref string error)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into jbxx_khdaH (");
            strSql.Append("DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,bmh,bmmc,khbh,khmc,khgm,lxr,xwy,khlx,qybh,khqy,sjqymc,sjqybh,khsr,zkdj,zk,fkzk,sjhm,ljjf,dhhm,cjhm,dz,yb,dzyj,wz,khyh,zjhm,qqhm,hykh,mm,sfgs,ksye,bqjf,ljxf,scbksj,bz,zjycxfrq,zjycxfje,zjycxfdh,yskje,djye,djyh,djsj,xgyh,xgsj,dmmc, sqjf) values (");
            strSql.Append("@DjLsh,@DjBtZdh,@DjFtZdh,@DjStZdh,@DjState,@DjCount,@bmh,@bmmc,@khbh,@khmc,@khgm,@lxr,@xwy,@khlx,@qybh,@khqy,@sjqymc,@sjqybh,@khsr,@zkdj,@zk,@fkzk,@sjhm,@ljjf,@dhhm,@cjhm,@dz,@yb,@dzyj,@wz,@khyh,@zjhm,@qqhm,@hykh,@mm,@sfgs,@ksye,@bqjf,@ljxf,@scbksj,@bz,@zjycxfrq,@zjycxfje,@zjycxfdh,@yskje,@djye,@djyh,@djsj,@xgyh,@xgsj,@dmmc,@sqjf) ");
            SqlParameter[] parameters = {

            new SqlParameter("@DjLsh",SqlDbType.Int,4),

            new SqlParameter("@DjBtZdh",SqlDbType.Int,4),

            new SqlParameter("@DjFtZdh",SqlDbType.Int,4),

            new SqlParameter("@DjStZdh",SqlDbType.Int,4),

            new SqlParameter("@DjState",SqlDbType.Char,10),

            new SqlParameter("@DjCount",SqlDbType.Int,4),

            new SqlParameter("@bmh",SqlDbType.VarChar,50),

            new SqlParameter("@bmmc",SqlDbType.VarChar,50),

            new SqlParameter("@khbh",SqlDbType.VarChar,50),

            new SqlParameter("@khmc",SqlDbType.VarChar,50),

            new SqlParameter("@khgm",SqlDbType.VarChar,50),

            new SqlParameter("@lxr",SqlDbType.VarChar,50),

            new SqlParameter("@xwy",SqlDbType.VarChar,50),

            new SqlParameter("@khlx",SqlDbType.VarChar,50),

            new SqlParameter("@qybh",SqlDbType.VarChar,50),

            new SqlParameter("@khqy",SqlDbType.VarChar,50),

            new SqlParameter("@sjqymc",SqlDbType.VarChar,50),

            new SqlParameter("@sjqybh",SqlDbType.VarChar,50),

            new SqlParameter("@khsr",SqlDbType.DateTime),

            new SqlParameter("@zkdj",SqlDbType.VarChar,50),

            new SqlParameter("@zk",SqlDbType.Decimal,9),

            new SqlParameter("@fkzk",SqlDbType.Decimal,9),

            new SqlParameter("@sjhm",SqlDbType.VarChar,50),

            new SqlParameter("@ljjf",SqlDbType.Decimal,9),

            new SqlParameter("@dhhm",SqlDbType.VarChar,50),

            new SqlParameter("@cjhm",SqlDbType.VarChar,50),

            new SqlParameter("@dz",SqlDbType.VarChar,50),

            new SqlParameter("@yb",SqlDbType.VarChar,50),

            new SqlParameter("@dzyj",SqlDbType.VarChar,50),

            new SqlParameter("@wz",SqlDbType.VarChar,50),

            new SqlParameter("@khyh",SqlDbType.VarChar,50),

            new SqlParameter("@zjhm",SqlDbType.VarChar,50),

            new SqlParameter("@qqhm",SqlDbType.VarChar,50),

            new SqlParameter("@hykh",SqlDbType.VarChar,50),

            new SqlParameter("@mm",SqlDbType.VarChar,50),

            new SqlParameter("@sfgs",SqlDbType.VarChar,50),

            new SqlParameter("@ksye",SqlDbType.Decimal,9),

            new SqlParameter("@bqjf",SqlDbType.Decimal,9),

            new SqlParameter("@ljxf",SqlDbType.Decimal,9),

            new SqlParameter("@scbksj",SqlDbType.DateTime),

            new SqlParameter("@bz",SqlDbType.VarChar,50),

            new SqlParameter("@zjycxfrq",SqlDbType.DateTime),

            new SqlParameter("@zjycxfje",SqlDbType.Decimal,9),

            new SqlParameter("@zjycxfdh",SqlDbType.VarChar,50),

            new SqlParameter("@yskje",SqlDbType.Decimal,9),

            new SqlParameter("@djye",SqlDbType.Decimal,9),

            new SqlParameter("@djyh",SqlDbType.VarChar,50),

            new SqlParameter("@djsj",SqlDbType.DateTime),

            new SqlParameter("@xgyh",SqlDbType.VarChar,50),

            new SqlParameter("@xgsj",SqlDbType.DateTime),

            new SqlParameter("@dmmc",SqlDbType.VarChar,50),

            new SqlParameter("@sqjf",SqlDbType.VarChar,50)
     };

            if (model.DjLsh != null)

                parameters[0].Value = model.DjLsh;
            else
                parameters[0].Value = DBNull.Value;

            if (model.DjBtZdh != null)

                parameters[1].Value = model.DjBtZdh;
            else
                parameters[1].Value = DBNull.Value;

            if (model.DjFtZdh != null)

                parameters[2].Value = model.DjFtZdh;
            else
                parameters[2].Value = DBNull.Value;

            if (model.DjStZdh != null)

                parameters[3].Value = model.DjStZdh;
            else
                parameters[3].Value = DBNull.Value;

            if (model.DjState != null)

                parameters[4].Value = model.DjState;
            else
                parameters[4].Value = DBNull.Value;

            if (model.DjCount != null)

                parameters[5].Value = model.DjCount;
            else
                parameters[5].Value = DBNull.Value;

            if (model.bmh != null)

                parameters[6].Value = model.bmh;
            else
                parameters[6].Value = DBNull.Value;

            if (model.bmmc != null)

                parameters[7].Value = model.bmmc;
            else
                parameters[7].Value = DBNull.Value;

            if (model.khbh != null)

                parameters[8].Value = model.khbh;
            else
                parameters[8].Value = DBNull.Value;

            if (model.khmc != null)

                parameters[9].Value = model.khmc;
            else
                parameters[9].Value = DBNull.Value;

            if (model.khgm != null)

                parameters[10].Value = model.khgm;
            else
                parameters[10].Value = DBNull.Value;

            if (model.lxr != null)

                parameters[11].Value = model.lxr;
            else
                parameters[11].Value = DBNull.Value;

            if (model.xwy != null)

                parameters[12].Value = model.xwy;
            else
                parameters[12].Value = DBNull.Value;

            if (model.khlx != null)

                parameters[13].Value = model.khlx;
            else
                parameters[13].Value = DBNull.Value;

            if (model.qybh != null)

                parameters[14].Value = model.qybh;
            else
                parameters[14].Value = DBNull.Value;

            if (model.khqy != null)

                parameters[15].Value = model.khqy;
            else
                parameters[15].Value = DBNull.Value;

            if (model.sjqymc != null)

                parameters[16].Value = model.sjqymc;
            else
                parameters[16].Value = DBNull.Value;

            if (model.sjqybh != null)

                parameters[17].Value = model.sjqybh;
            else
                parameters[17].Value = DBNull.Value;

            if (model.khsr != null && !model.khsr.ToString().Contains("0001/1/1"))

                parameters[18].Value = model.khsr;
            else
                parameters[18].Value = DBNull.Value;

            if (model.zkdj != null)

                //zjycxfrq = {0001/1/1 星期一 0:00:00}

                parameters[19].Value = model.zkdj;
            else
                parameters[19].Value = DBNull.Value;

            if (model.zk != null)

                parameters[20].Value = model.zk;
            else
                parameters[20].Value = DBNull.Value;

            if (model.fkzk != null)

                parameters[21].Value = model.fkzk;
            else
                parameters[21].Value = DBNull.Value;

            if (model.sjhm != null)

                parameters[22].Value = model.sjhm;
            else
                parameters[22].Value = DBNull.Value;

            if (model.ljjf != null)

                parameters[23].Value = model.ljjf;
            else
                parameters[23].Value = DBNull.Value;

            if (model.dhhm != null)

                parameters[24].Value = model.dhhm;
            else
                parameters[24].Value = DBNull.Value;

            if (model.cjhm != null)

                parameters[25].Value = model.cjhm;
            else
                parameters[25].Value = DBNull.Value;

            if (model.dz != null)

                parameters[26].Value = model.dz;
            else
                parameters[26].Value = DBNull.Value;

            if (model.yb != null)

                parameters[27].Value = model.yb;
            else
                parameters[27].Value = DBNull.Value;

            if (model.dzyj != null)

                parameters[28].Value = model.dzyj;
            else
                parameters[28].Value = DBNull.Value;

            if (model.wz != null)

                parameters[29].Value = model.wz;
            else
                parameters[29].Value = DBNull.Value;

            if (model.khyh != null)

                parameters[30].Value = model.khyh;
            else
                parameters[30].Value = DBNull.Value;

            if (model.zjhm != null)

                parameters[31].Value = model.zjhm;
            else
                parameters[31].Value = DBNull.Value;

            if (model.qqhm != null)

                parameters[32].Value = model.qqhm;
            else
                parameters[32].Value = DBNull.Value;

            if (model.hykh != null)

                parameters[33].Value = model.hykh;
            else
                parameters[33].Value = DBNull.Value;

            if (model.mm != null)

                parameters[34].Value = model.mm;
            else
                parameters[34].Value = DBNull.Value;

            if (model.sfgs != null)

                parameters[35].Value = model.sfgs;
            else
                parameters[35].Value = DBNull.Value;

            if (model.ksye != null)

                parameters[36].Value = model.ksye;
            else
                parameters[36].Value = DBNull.Value;

            if (model.bqjf != null)

                parameters[37].Value = model.bqjf;
            else
                parameters[37].Value = DBNull.Value;

            if (model.ljxf != null)

                parameters[38].Value = model.ljxf;
            else
                parameters[38].Value = DBNull.Value;

            if (model.scbksj != null && !model.scbksj.ToString().Contains("0001/1/1"))

                parameters[39].Value = model.scbksj;
            else
                parameters[39].Value = DBNull.Value;

            if (model.bz != null)

                parameters[40].Value = model.bz;
            else
                parameters[40].Value = DBNull.Value;

            if (model.zjycxfrq != null && !model.zjycxfrq.ToString().Contains("0001/1/1"))

                parameters[41].Value = model.zjycxfrq;
            else
                parameters[41].Value = DBNull.Value;

            if (model.zjycxfje != null)

                parameters[42].Value = model.zjycxfje;
            else
                parameters[42].Value = DBNull.Value;

            if (model.zjycxfdh != null)

                parameters[43].Value = model.zjycxfdh;
            else
                parameters[43].Value = DBNull.Value;

            if (model.yskje != null)

                parameters[44].Value = model.yskje;
            else
                parameters[44].Value = DBNull.Value;

            if (model.djye != null)

                parameters[45].Value = model.djye;
            else
                parameters[45].Value = DBNull.Value;

            if (model.djyh != null)

                parameters[46].Value = model.djyh;
            else
                parameters[46].Value = DBNull.Value;

            if (model.djsj != null)

                parameters[47].Value = model.djsj;
            else
                parameters[47].Value = DBNull.Value;

            if (model.xgyh != null)

                parameters[48].Value = model.xgyh;
            else
                parameters[48].Value = DBNull.Value;

            if (model.xgsj != null)

                parameters[49].Value = model.xgsj;
            else
                parameters[49].Value = DBNull.Value;

            if (model.dmmc != null)

                parameters[50].Value = model.dmmc;
            else
                parameters[50].Value = DBNull.Value;

            if (model.sqjf != null)

                parameters[51].Value = model.sqjf;
            else
                parameters[51].Value = DBNull.Value;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters, ref error);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary> 
        /// 增加一条数据(字符串) 
        /// </summary> 
        public string AddStr(jbxx_khdaH_Entity model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into jbxx_khdaH(");
            strSql.Append("DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,bmh,bmmc,khbh,khmc,khgm,lxr,xwy,khlx,qybh,khqy,sjqymc,sjqybh,khsr,zkdj,zk,fkzk,sjhm,ljjf,dhhm,cjhm,dz,yb,dzyj,wz,khyh,zjhm,qqhm,hykh,mm,sfgs,ksye,bqjf,ljxf,scbksj,bz,zjycxfrq,zjycxfje,zjycxfdh,yskje,djye,djyh,djsj,xgyh,xgsj,dmmc, sqjf) values (");
            strSql.Append("'" + model.DjLsh + "','" + model.DjBtZdh + "','" + model.DjFtZdh + "','" + model.DjStZdh + "','" + model.DjState + "','" + model.DjCount + "','" + model.bmh + "','" + model.bmmc + "','" + model.khbh + "','" + model.khmc + "','" + model.khgm + "','" + model.lxr + "','" + model.xwy + "','" + model.khlx + "','" + model.qybh + "','" + model.khqy + "','" + model.sjqymc + "','" + model.sjqybh + "','" + model.khsr + "','" + model.zkdj + "','" + model.zk + "','" + model.fkzk + "','" + model.sjhm + "','" + model.ljjf + "','" + model.dhhm + "','" + model.cjhm + "','" + model.dz + "','" + model.yb + "','" + model.dzyj + "','" + model.wz + "','" + model.khyh + "','" + model.zjhm + "','" + model.qqhm + "','" + model.hykh + "','" + model.mm + "','" + model.sfgs + "','" + model.ksye + "','" + model.bqjf + "','" + model.ljxf + "','" + model.scbksj + "','" + model.bz + "','" + model.zjycxfrq + "','" + model.zjycxfje + "','" + model.zjycxfdh + "','" + model.yskje + "','" + model.djye + "','" + model.djyh + "','" + model.djsj + "','" + model.xgyh + "','" + model.xgsj + "','" + model.dmmc + "','" + model.sqjf + "') ");
            return strSql.ToString();
        }
        /// <summary> 
        /// 更新一条数据 
        ///创建时间:2020-04-09
        ///创建人:minjie
        /// </summary> 
        public bool Update(jbxx_khdaH_Entity model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update jbxx_khdaH set ");
            strSql.Append(" DjLsh = @DjLsh,");

            strSql.Append(" DjBtZdh = @DjBtZdh,");

            strSql.Append(" DjFtZdh = @DjFtZdh,");

            strSql.Append(" DjStZdh = @DjStZdh,");

            strSql.Append(" DjState = @DjState,");

            strSql.Append(" DjCount = @DjCount,");

            strSql.Append(" bmh = @bmh,");

            strSql.Append(" bmmc = @bmmc,");

            strSql.Append(" khbh = @khbh,");

            strSql.Append(" khmc = @khmc,");

            strSql.Append(" khgm = @khgm,");

            strSql.Append(" lxr = @lxr,");

            strSql.Append(" xwy = @xwy,");

            strSql.Append(" khlx = @khlx,");

            strSql.Append(" qybh = @qybh,");

            strSql.Append(" khqy = @khqy,");

            strSql.Append(" sjqymc = @sjqymc,");

            strSql.Append(" sjqybh = @sjqybh,");

            strSql.Append(" khsr = @khsr,");

            strSql.Append(" zkdj = @zkdj,");

            strSql.Append(" zk = @zk,");

            strSql.Append(" fkzk = @fkzk,");

            strSql.Append(" sjhm = @sjhm,");

            strSql.Append(" ljjf = @ljjf,");

            strSql.Append(" dhhm = @dhhm,");

            strSql.Append(" cjhm = @cjhm,");

            strSql.Append(" dz = @dz,");

            strSql.Append(" yb = @yb,");

            strSql.Append(" dzyj = @dzyj,");

            strSql.Append(" wz = @wz,");

            strSql.Append(" khyh = @khyh,");

            strSql.Append(" zjhm = @zjhm,");

            strSql.Append(" qqhm = @qqhm,");

            strSql.Append(" hykh = @hykh,");

            strSql.Append(" mm = @mm,");

            strSql.Append(" sfgs = @sfgs,");

            strSql.Append(" ksye = @ksye,");

            strSql.Append(" bqjf = @bqjf,");

            strSql.Append(" ljxf = @ljxf,");

            strSql.Append(" scbksj = @scbksj,");

            strSql.Append(" bz = @bz,");

            strSql.Append(" zjycxfrq = @zjycxfrq,");

            strSql.Append(" zjycxfje = @zjycxfje,");

            strSql.Append(" zjycxfdh = @zjycxfdh,");

            strSql.Append(" yskje = @yskje,");

            strSql.Append(" djye = @djye,");

            strSql.Append(" djyh = @djyh,");

            strSql.Append(" djsj = @djsj,");

            strSql.Append(" xgyh = @xgyh,");

            strSql.Append(" xgsj = @xgsj,");

            strSql.Append(" dmmc = @dmmc,");

            strSql.Append(" sqjf = @sqjf");


            strSql.Append(" where  DjLsh =@DjLsh ");
            SqlParameter[] parameters = {

            new SqlParameter("@DjLsh",SqlDbType.Int,4),

            new SqlParameter("@DjBtZdh",SqlDbType.Int,4),

            new SqlParameter("@DjFtZdh",SqlDbType.Int,4),

            new SqlParameter("@DjStZdh",SqlDbType.Int,4),

            new SqlParameter("@DjState",SqlDbType.Char,10),

            new SqlParameter("@DjCount",SqlDbType.Int,4),

            new SqlParameter("@bmh",SqlDbType.VarChar,50),

            new SqlParameter("@bmmc",SqlDbType.VarChar,50),

            new SqlParameter("@khbh",SqlDbType.VarChar,50),

            new SqlParameter("@khmc",SqlDbType.VarChar,50),

            new SqlParameter("@khgm",SqlDbType.VarChar,50),

            new SqlParameter("@lxr",SqlDbType.VarChar,50),

            new SqlParameter("@xwy",SqlDbType.VarChar,50),

            new SqlParameter("@khlx",SqlDbType.VarChar,50),

            new SqlParameter("@qybh",SqlDbType.VarChar,50),

            new SqlParameter("@khqy",SqlDbType.VarChar,50),

            new SqlParameter("@sjqymc",SqlDbType.VarChar,50),

            new SqlParameter("@sjqybh",SqlDbType.VarChar,50),

            new SqlParameter("@khsr",SqlDbType.DateTime),

            new SqlParameter("@zkdj",SqlDbType.VarChar,50),

            new SqlParameter("@zk",SqlDbType.Decimal,9),

            new SqlParameter("@fkzk",SqlDbType.Decimal,9),

            new SqlParameter("@sjhm",SqlDbType.VarChar,50),

            new SqlParameter("@ljjf",SqlDbType.Decimal,9),

            new SqlParameter("@dhhm",SqlDbType.VarChar,50),

            new SqlParameter("@cjhm",SqlDbType.VarChar,50),

            new SqlParameter("@dz",SqlDbType.VarChar,50),

            new SqlParameter("@yb",SqlDbType.VarChar,50),

            new SqlParameter("@dzyj",SqlDbType.VarChar,50),

            new SqlParameter("@wz",SqlDbType.VarChar,50),

            new SqlParameter("@khyh",SqlDbType.VarChar,50),

            new SqlParameter("@zjhm",SqlDbType.VarChar,50),

            new SqlParameter("@qqhm",SqlDbType.VarChar,50),

            new SqlParameter("@hykh",SqlDbType.VarChar,50),

            new SqlParameter("@mm",SqlDbType.VarChar,50),

            new SqlParameter("@sfgs",SqlDbType.VarChar,50),

            new SqlParameter("@ksye",SqlDbType.Decimal,9),

            new SqlParameter("@bqjf",SqlDbType.Decimal,9),

            new SqlParameter("@ljxf",SqlDbType.Decimal,9),

            new SqlParameter("@scbksj",SqlDbType.DateTime),

            new SqlParameter("@bz",SqlDbType.VarChar,50),

            new SqlParameter("@zjycxfrq",SqlDbType.DateTime),

            new SqlParameter("@zjycxfje",SqlDbType.Decimal,9),

            new SqlParameter("@zjycxfdh",SqlDbType.VarChar,50),

            new SqlParameter("@yskje",SqlDbType.Decimal,9),

            new SqlParameter("@djye",SqlDbType.Decimal,9),

            new SqlParameter("@djyh",SqlDbType.VarChar,50),

            new SqlParameter("@djsj",SqlDbType.DateTime),

            new SqlParameter("@xgyh",SqlDbType.VarChar,50),

            new SqlParameter("@xgsj",SqlDbType.DateTime),

            new SqlParameter("@dmmc",SqlDbType.VarChar,50),

            new SqlParameter("@sqjf",SqlDbType.VarChar,50)
     };

            if (model.DjLsh != null)

                parameters[0].Value = model.DjLsh;
            else
                parameters[0].Value = DBNull.Value;

            if (model.DjBtZdh != null)

                parameters[1].Value = model.DjBtZdh;
            else
                parameters[1].Value = DBNull.Value;

            if (model.DjFtZdh != null)

                parameters[2].Value = model.DjFtZdh;
            else
                parameters[2].Value = DBNull.Value;

            if (model.DjStZdh != null)

                parameters[3].Value = model.DjStZdh;
            else
                parameters[3].Value = DBNull.Value;

            if (model.DjState != null)

                parameters[4].Value = model.DjState;
            else
                parameters[4].Value = DBNull.Value;

            if (model.DjCount != null)

                parameters[5].Value = model.DjCount;
            else
                parameters[5].Value = DBNull.Value;

            if (model.bmh != null)

                parameters[6].Value = model.bmh;
            else
                parameters[6].Value = DBNull.Value;

            if (model.bmmc != null)

                parameters[7].Value = model.bmmc;
            else
                parameters[7].Value = DBNull.Value;

            if (model.khbh != null)

                parameters[8].Value = model.khbh;
            else
                parameters[8].Value = DBNull.Value;

            if (model.khmc != null)

                parameters[9].Value = model.khmc;
            else
                parameters[9].Value = DBNull.Value;

            if (model.khgm != null)

                parameters[10].Value = model.khgm;
            else
                parameters[10].Value = DBNull.Value;

            if (model.lxr != null)

                parameters[11].Value = model.lxr;
            else
                parameters[11].Value = DBNull.Value;

            if (model.xwy != null)

                parameters[12].Value = model.xwy;
            else
                parameters[12].Value = DBNull.Value;

            if (model.khlx != null)

                parameters[13].Value = model.khlx;
            else
                parameters[13].Value = DBNull.Value;

            if (model.qybh != null)

                parameters[14].Value = model.qybh;
            else
                parameters[14].Value = DBNull.Value;

            if (model.khqy != null)

                parameters[15].Value = model.khqy;
            else
                parameters[15].Value = DBNull.Value;

            if (model.sjqymc != null)

                parameters[16].Value = model.sjqymc;
            else
                parameters[16].Value = DBNull.Value;

            if (model.sjqybh != null)

                parameters[17].Value = model.sjqybh;
            else
                parameters[17].Value = DBNull.Value;

            if (model.khsr != null)

                parameters[18].Value = model.khsr;
            else
                parameters[18].Value = DBNull.Value;

            if (model.zkdj != null)

                parameters[19].Value = model.zkdj;
            else
                parameters[19].Value = DBNull.Value;

            if (model.zk != null)

                parameters[20].Value = model.zk;
            else
                parameters[20].Value = DBNull.Value;

            if (model.fkzk != null)

                parameters[21].Value = model.fkzk;
            else
                parameters[21].Value = DBNull.Value;

            if (model.sjhm != null)

                parameters[22].Value = model.sjhm;
            else
                parameters[22].Value = DBNull.Value;

            if (model.ljjf != null)

                parameters[23].Value = model.ljjf;
            else
                parameters[23].Value = DBNull.Value;

            if (model.dhhm != null)

                parameters[24].Value = model.dhhm;
            else
                parameters[24].Value = DBNull.Value;

            if (model.cjhm != null)

                parameters[25].Value = model.cjhm;
            else
                parameters[25].Value = DBNull.Value;

            if (model.dz != null)

                parameters[26].Value = model.dz;
            else
                parameters[26].Value = DBNull.Value;

            if (model.yb != null)

                parameters[27].Value = model.yb;
            else
                parameters[27].Value = DBNull.Value;

            if (model.dzyj != null)

                parameters[28].Value = model.dzyj;
            else
                parameters[28].Value = DBNull.Value;

            if (model.wz != null)

                parameters[29].Value = model.wz;
            else
                parameters[29].Value = DBNull.Value;

            if (model.khyh != null)

                parameters[30].Value = model.khyh;
            else
                parameters[30].Value = DBNull.Value;

            if (model.zjhm != null)

                parameters[31].Value = model.zjhm;
            else
                parameters[31].Value = DBNull.Value;

            if (model.qqhm != null)

                parameters[32].Value = model.qqhm;
            else
                parameters[32].Value = DBNull.Value;

            if (model.hykh != null)

                parameters[33].Value = model.hykh;
            else
                parameters[33].Value = DBNull.Value;

            if (model.mm != null)

                parameters[34].Value = model.mm;
            else
                parameters[34].Value = DBNull.Value;

            if (model.sfgs != null)

                parameters[35].Value = model.sfgs;
            else
                parameters[35].Value = DBNull.Value;

            if (model.ksye != null)

                parameters[36].Value = model.ksye;
            else
                parameters[36].Value = DBNull.Value;

            if (model.bqjf != null)

                parameters[37].Value = model.bqjf;
            else
                parameters[37].Value = DBNull.Value;

            if (model.ljxf != null)

                parameters[38].Value = model.ljxf;
            else
                parameters[38].Value = DBNull.Value;

            if (model.scbksj != null)

                parameters[39].Value = model.scbksj;
            else
                parameters[39].Value = DBNull.Value;

            if (model.bz != null)

                parameters[40].Value = model.bz;
            else
                parameters[40].Value = DBNull.Value;

            if (model.zjycxfrq != null)

                parameters[41].Value = model.zjycxfrq;
            else
                parameters[41].Value = DBNull.Value;

            if (model.zjycxfje != null)

                parameters[42].Value = model.zjycxfje;
            else
                parameters[42].Value = DBNull.Value;

            if (model.zjycxfdh != null)

                parameters[43].Value = model.zjycxfdh;
            else
                parameters[43].Value = DBNull.Value;

            if (model.yskje != null)

                parameters[44].Value = model.yskje;
            else
                parameters[44].Value = DBNull.Value;

            if (model.djye != null)

                parameters[45].Value = model.djye;
            else
                parameters[45].Value = DBNull.Value;

            if (model.djyh != null)

                parameters[46].Value = model.djyh;
            else
                parameters[46].Value = DBNull.Value;

            if (model.djsj != null)

                parameters[47].Value = model.djsj;
            else
                parameters[47].Value = DBNull.Value;

            if (model.xgyh != null)

                parameters[48].Value = model.xgyh;
            else
                parameters[48].Value = DBNull.Value;

            if (model.xgsj != null)

                parameters[49].Value = model.xgsj;
            else
                parameters[49].Value = DBNull.Value;

            if (model.dmmc != null)

                parameters[50].Value = model.dmmc;
            else
                parameters[50].Value = DBNull.Value;

            if (model.sqjf != null)

                parameters[51].Value = model.sqjf;
            else
                parameters[51].Value = DBNull.Value;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary> 
        /// 删除一条数据 
        /// </summary> 
        public bool Delete(int DjLsh)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from jbxx_khdaH ");
            strSql.Append(" where   DjLsh =@DjLsh ");
            SqlParameter[] parameters = { new SqlParameter("@DjLsh", SqlDbType.Int, 4) };
            parameters[0].Value = DjLsh;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary> 
        /// 批量删除一批数据 
        /// </summary> 
        public bool DeleteList(string lists)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from sys_Config ");
            strSql.Append(" where DjLsh in (" + lists + ")  ");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary> 
        /// 得到一个对象实体 
        /// </summary> 
        public jbxx_khdaH_Entity GetModel(int DjLsh)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1  DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,bmh,bmmc,khbh,khmc,khgm,lxr,xwy,khlx,qybh,khqy,sjqymc,sjqybh,khsr,zkdj,zk,fkzk,sjhm,ljjf,dhhm,cjhm,dz,yb,dzyj,wz,khyh,zjhm,qqhm,hykh,mm,sfgs,ksye,bqjf,ljxf,scbksj,bz,zjycxfrq,zjycxfje,zjycxfdh,yskje,djye,djyh,djsj,xgyh,xgsj,dmmc, sqjf ");
            strSql.Append(" from jbxx_khdaH where DjLsh="+ DjLsh);
            jbxx_khdaH_Entity model = new jbxx_khdaH_Entity();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            DataTable dt = ds.Tables[0];
            return DataTableToEntity(dt);
        }

        public jbxx_khdaH_Entity GetModel()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1  DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,bmh,bmmc,khbh,khmc,khgm,lxr,xwy,khlx,qybh,khqy,sjqymc,sjqybh,khsr,zkdj,zk,fkzk,sjhm,ljjf,dhhm,cjhm,dz,yb,dzyj,wz,khyh,zjhm,qqhm,hykh,mm,sfgs,ksye,bqjf,ljxf,scbksj,bz,zjycxfrq,zjycxfje,zjycxfdh,yskje,djye,djyh,djsj,xgyh,xgsj,dmmc, sqjf ");
            strSql.Append(" from jbxx_khdaH  order by DjLsh desc ");
            jbxx_khdaH_Entity model = new jbxx_khdaH_Entity();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            DataTable dt = ds.Tables[0];
            return DataTableToEntity(dt);
        }


        /// <summary> 
        /// 将数据集(DataTable)转换 对象 jbxx_khdaH_Entity
        /// 创建人：minjie 
        /// 创建时间:2019-02-18 02:05:58 
        /// </summary> 
        public jbxx_khdaH_Entity DataTableToEntity(DataTable dt)
        {
            jbxx_khdaH_Entity model = new jbxx_khdaH_Entity();
            if (dt != null && dt.Rows.Count > 0)
            {

                if (dt.Rows[0]["DjLsh"] != null && dt.Rows[0]["DjLsh"].ToString() != "")
                    model.DjLsh = int.Parse(dt.Rows[0]["DjLsh"].ToString());


                if (dt.Rows[0]["DjBtZdh"] != null && dt.Rows[0]["DjBtZdh"].ToString() != "")
                    model.DjBtZdh = int.Parse(dt.Rows[0]["DjBtZdh"].ToString());


                if (dt.Rows[0]["DjFtZdh"] != null && dt.Rows[0]["DjFtZdh"].ToString() != "")
                    model.DjFtZdh = int.Parse(dt.Rows[0]["DjFtZdh"].ToString());


                if (dt.Rows[0]["DjStZdh"] != null && dt.Rows[0]["DjStZdh"].ToString() != "")
                    model.DjStZdh = int.Parse(dt.Rows[0]["DjStZdh"].ToString());

                model.DjState = dt.Rows[0]["DjState"].ToString();

                if (dt.Rows[0]["DjCount"] != null && dt.Rows[0]["DjCount"].ToString() != "")
                    model.DjCount = int.Parse(dt.Rows[0]["DjCount"].ToString());

                model.bmh = dt.Rows[0]["bmh"].ToString();
                model.bmmc = dt.Rows[0]["bmmc"].ToString();
                model.khbh = dt.Rows[0]["khbh"].ToString();
                model.khmc = dt.Rows[0]["khmc"].ToString();
                model.khgm = dt.Rows[0]["khgm"].ToString();
                model.lxr = dt.Rows[0]["lxr"].ToString();
                model.xwy = dt.Rows[0]["xwy"].ToString();
                model.khlx = dt.Rows[0]["khlx"].ToString();
                model.qybh = dt.Rows[0]["qybh"].ToString();
                model.khqy = dt.Rows[0]["khqy"].ToString();
                model.sjqymc = dt.Rows[0]["sjqymc"].ToString();
                model.sjqybh = dt.Rows[0]["sjqybh"].ToString();
                if (dt.Rows[0]["khsr"] != null && dt.Rows[0]["khsr"].ToString() != "")
                    model.khsr = DateTime.Parse(dt.Rows[0]["khsr"].ToString());

                model.zkdj = dt.Rows[0]["zkdj"].ToString();
                if (dt.Rows[0]["zk"] != null && dt.Rows[0]["zk"].ToString() != "")
                    model.zk = decimal.Parse(dt.Rows[0]["zk"].ToString());

                if (dt.Rows[0]["fkzk"] != null && dt.Rows[0]["fkzk"].ToString() != "")
                    model.fkzk = decimal.Parse(dt.Rows[0]["fkzk"].ToString());

                model.sjhm = dt.Rows[0]["sjhm"].ToString();
                if (dt.Rows[0]["ljjf"] != null && dt.Rows[0]["ljjf"].ToString() != "")
                    model.ljjf = decimal.Parse(dt.Rows[0]["ljjf"].ToString());

                model.dhhm = dt.Rows[0]["dhhm"].ToString();
                model.cjhm = dt.Rows[0]["cjhm"].ToString();
                model.dz = dt.Rows[0]["dz"].ToString();
                model.yb = dt.Rows[0]["yb"].ToString();
                model.dzyj = dt.Rows[0]["dzyj"].ToString();
                model.wz = dt.Rows[0]["wz"].ToString();
                model.khyh = dt.Rows[0]["khyh"].ToString();
                model.zjhm = dt.Rows[0]["zjhm"].ToString();
                model.qqhm = dt.Rows[0]["qqhm"].ToString();
                model.hykh = dt.Rows[0]["hykh"].ToString();
                model.mm = dt.Rows[0]["mm"].ToString();
                model.sfgs = dt.Rows[0]["sfgs"].ToString();
                if (dt.Rows[0]["ksye"] != null && dt.Rows[0]["ksye"].ToString() != "")
                    model.ksye = decimal.Parse(dt.Rows[0]["ksye"].ToString());

                if (dt.Rows[0]["bqjf"] != null && dt.Rows[0]["bqjf"].ToString() != "")
                    model.bqjf = decimal.Parse(dt.Rows[0]["bqjf"].ToString());

                if (dt.Rows[0]["ljxf"] != null && dt.Rows[0]["ljxf"].ToString() != "")
                    model.ljxf = decimal.Parse(dt.Rows[0]["ljxf"].ToString());

                if (dt.Rows[0]["scbksj"] != null && dt.Rows[0]["scbksj"].ToString() != "")
                    model.scbksj = DateTime.Parse(dt.Rows[0]["scbksj"].ToString());

                model.bz = dt.Rows[0]["bz"].ToString();
                if (dt.Rows[0]["zjycxfrq"] != null && dt.Rows[0]["zjycxfrq"].ToString() != "")
                    model.zjycxfrq = DateTime.Parse(dt.Rows[0]["zjycxfrq"].ToString());

                if (dt.Rows[0]["zjycxfje"] != null && dt.Rows[0]["zjycxfje"].ToString() != "")
                    model.zjycxfje = decimal.Parse(dt.Rows[0]["zjycxfje"].ToString());

                model.zjycxfdh = dt.Rows[0]["zjycxfdh"].ToString();
                if (dt.Rows[0]["yskje"] != null && dt.Rows[0]["yskje"].ToString() != "")
                    model.yskje = decimal.Parse(dt.Rows[0]["yskje"].ToString());

                if (dt.Rows[0]["djye"] != null && dt.Rows[0]["djye"].ToString() != "")
                    model.djye = decimal.Parse(dt.Rows[0]["djye"].ToString());

                model.djyh = dt.Rows[0]["djyh"].ToString();
                if (dt.Rows[0]["djsj"] != null && dt.Rows[0]["djsj"].ToString() != "")
                    model.djsj = DateTime.Parse(dt.Rows[0]["djsj"].ToString());

                model.xgyh = dt.Rows[0]["xgyh"].ToString();
                if (dt.Rows[0]["xgsj"] != null && dt.Rows[0]["xgsj"].ToString() != "")
                    model.xgsj = DateTime.Parse(dt.Rows[0]["xgsj"].ToString());

                model.dmmc = dt.Rows[0]["dmmc"].ToString();
                model.sqjf = dt.Rows[0]["sqjf"].ToString();

                return model;
            }
            else
            {
                return null;
            }
        }



        /// <summary> 
        /// 执行sql语句  
        /// </summary> 
        public string GetSingle(string sql)
        {
            object obj = DbHelperSQL.GetSingle(sql);
            if (obj != null)
            {
                return obj.ToString();
            }
            else
                return "";
        }
        /// <summary> 
        /// 直接执行sql语句 
        /// </summary> 
        public int ExecuteSql(string sql)
        {
            return DbHelperSQL.ExecuteSql(sql);
        }



        /// <summary> 
        /// 直接执行sql语句 
        /// </summary> 
        public DataTable ExecuteDt(string sql)
        {
            return DbHelperSQL.ExecuteDt(sql);
        }

        /// <summary> 
        /// 获得记录条数 
        /// </summary> 
        public int GetRecordCount(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) ");
            strSql.Append(" FROM jbxx_khdaH ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj != null && obj.ToString() != "")
                return Convert.ToInt32(obj);
            else
                return 0;
        }
        /// <summary> 
        /// 批量处理  
        /// </summary> 
        public int ExecuteSqlTran(List<string> ls, ref string error)
        {
            return DbHelperSQL.ExecuteSqlTran(ls, ref error);
        }
        /// <summary> 
        /// 分页获取数据列表 
        /// </summary> 
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by " + orderby);
            }
            else
            {
                strSql.Append("order by T.DjLsh desc");
            }
            strSql.Append(")AS Row, T.*  from jbxx_khdaH  T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
            return DbHelperSQL.Query(strSql.ToString());
        }
        /// <summary> 
        /// 获得数据列表 
        /// </summary> 
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM jbxx_khdaH ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }
    }
}
